Skip to content

fix(cli): move top-level command routing into folders#113

Merged
Agent-Hellboy merged 4 commits intomainfrom
cli/foldered_command_routing
May 1, 2026
Merged

fix(cli): move top-level command routing into folders#113
Agent-Hellboy merged 4 commits intomainfrom
cli/foldered_command_routing

Conversation

@Agent-Hellboy
Copy link
Copy Markdown
Owner

Keep CLI behavior unchanged while moving top-level Cobra routing into the foldered internal/cli command packages where the shared boundary is clean. Also document that agents must work from branches and PRs instead of pushing directly to main.

Keep CLI behavior unchanged while moving top-level Cobra routing into the foldered internal/cli command packages where the shared boundary is clean. Also document that agents must work from branches and PRs instead of pushing directly to main.
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the CLI by moving command definitions from the main internal/cli package into specific sub-packages, necessitating the exportation of various internal functions and methods. Documentation and agent guidelines were also updated. Feedback highlights opportunities to reduce code duplication by removing redundant routing logic and constants from the base package. A suggestion was also made to improve argument validation for the server creation command when using file-based inputs.

Comment on lines +12 to +13
grantResource = "mcpaccessgrant"
sessionResource = "mcpagentsession"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

These resource name constants are duplicated from internal/cli/access.go. To ensure consistency and avoid potential runtime errors if the strings diverge, consider exporting the constants from the cli package (e.g., AccessGrantResource) and referencing them here.

}

// NewWithManager returns the access command using the provided manager.
func NewWithManager(mgr *cli.AccessManager) *cobra.Command {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The command routing logic here is duplicated from internal/cli/access.go. To adhere to the PR's goal of moving routing into folders, the Cobra command definitions should be removed from the base cli package to ensure a single source of truth for command structures.

}

// NewWithManager returns the server command using the provided manager.
func NewWithManager(mgr *cli.ServerManager) *cobra.Command {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This function and the associated subcommand definitions are duplicated from internal/cli/server.go. To maintain code quality and avoid divergence, the routing logic should be removed from the base cli package now that it has been moved here.

Use: "create [name]",
Short: "Create an MCP server",
Long: "Create a new MCP server deployment",
Args: cobra.ExactArgs(1),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The ExactArgs(1) constraint causes the command to fail when the --file flag is used without a positional argument, even though the name argument is ignored in that case. A dynamic validator would provide a better user experience.

		Args: func(cmd *cobra.Command, args []string) error {
			if file != "" {
				return cobra.NoArgs(cmd, args)
			}
			return cobra.ExactArgs(1)(cmd, args)
		},

@codecov
Copy link
Copy Markdown

codecov Bot commented May 1, 2026

Codecov Report

❌ Patch coverage is 14.77636% with 1067 lines in your changes missing coverage. Please review.
✅ Project coverage is 51.64%. Comparing base (2eba85b) to head (2eef67a).
⚠️ Report is 9 commits behind head on main.

Files with missing lines Patch % Lines
internal/cli/server/server.go 0.00% 134 Missing ⚠️
internal/cli/auth/auth.go 40.09% 117 Missing and 16 partials ⚠️
internal/cli/bootstrap/bootstrap.go 0.00% 114 Missing ⚠️
internal/cli/setup/setup.go 0.00% 97 Missing ⚠️
internal/cli/pipeline/pipeline.go 37.41% 85 Missing and 7 partials ⚠️
internal/cli/access/access.go 0.00% 90 Missing ⚠️
internal/cli/cluster/cluster.go 0.00% 81 Missing ⚠️
internal/cli/sentinel/sentinel.go 0.00% 62 Missing ⚠️
internal/cli/registry.go 23.07% 56 Missing and 4 partials ⚠️
internal/cli/registry/registry.go 0.00% 56 Missing ⚠️
... and 16 more
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #113      +/-   ##
==========================================
- Coverage   58.01%   51.64%   -6.38%     
==========================================
  Files          70       72       +2     
  Lines       10700    10679      -21     
==========================================
- Hits         6208     5515     -693     
- Misses       3897     4580     +683     
+ Partials      595      584      -11     
Flag Coverage Δ
pre-merge 51.64% <14.77%> (-6.38%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
internal/cli/cert.go 94.87% <ø> (-3.86%) ⬇️
internal/cli/cluster_doctor.go 65.73% <ø> (+0.06%) ⬆️
internal/cli/root/commands.go 100.00% <100.00%> (ø)
internal/cli/status.go 71.69% <100.00%> (+0.26%) ⬆️
internal/cli/access.go 15.16% <0.00%> (-21.72%) ⬇️
internal/cli/build.go 94.16% <0.00%> (-2.02%) ⬇️
internal/cli/client.go 66.66% <0.00%> (-3.34%) ⬇️
internal/cli/sentinel.go 34.74% <0.00%> (-18.63%) ⬇️
internal/cli/cluster.go 75.53% <60.00%> (-5.49%) ⬇️
internal/cli/platform_client.go 29.31% <0.00%> (-0.29%) ⬇️
... and 20 more

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Build the shared CLI dependencies once in internal/cli and pass a runtime facade into the foldered command packages. Keep Cobra trees and command-local orchestration in the folders while shared managers and helpers stay in internal/cli.
Move the auth command manager, login flow, verification helpers, and tests into internal/cli/auth so the subcommand folder owns its command-specific behavior. Keep only the shared platform base-URL normalization helper in internal/cli for reuse by platform_client.
@Agent-Hellboy
Copy link
Copy Markdown
Owner Author

@codex please review

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Bravo.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@Agent-Hellboy Agent-Hellboy merged commit d7b3cbd into main May 1, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant